string->list, list->string - convert between strings and lists
LIBRARY
(import (rnrs)) ;R6RS
(import (rnrs base)) ;R6RS
(import (scheme r5rs)) ;R7RS
(import (scheme base)) ;R7RS
SYNOPSIS
(string->list string)
(string->list string start) ;R7RS
(string->list string start end) ;R7RS
(list->string list)
DESCRIPTION
The
string->list
procedure returns a newly allocated list of the characters that make
up the given string.
The
list->string
procedure returns a newly allocated string formed from the characters
in list.
These procedures are inverses so far as
equal?(3string)
is concerned, and preserve the order of the characters.
- R7RS
-
The
string->list
procedure returns a newly allocated list
of the characters of string between
start
(inclusive)
and
end
(exclusive).
IMPLEMENTATION NOTES
Some implementations have a single empty string object; see
make-string(3scm).
RETURN VALUES
Both of these procedures return a single value. The
string->list
procedure returns a list (a pair or the empty list); the
list->string
procedure returns a string object.
EXAMPLES
(string->list "Quux") => (#\Q #\u #\u #\x)
(list->string '(#\f #\o #\o)) => "foo"
APPLICATION USAGE
These procedures can be seen in some highly functional programming styles.
COMPATIBILITY
The
start
and
end
arguments are unique to R7RS. The only other difference between
implementations is whether the empty string is newly allocated or not
(see above).
ERRORS
This procedure can raise exceptions with the following condition types:
- &assertion (R6RS)
-
The wrong number of arguments was passed or an argument was outside its domain.
In particular,
list
must be a list of characters and
string
must be a string.
- R7RS
-
The assertions described above are errors.
Implementations may signal an error, extend the procedure's
domain of definition to include such arguments,
or fail catastrophically.
SEE ALSO
list->vector(3scm),
string-append(3scm)
STANDARDS
R4RS,
R5RS,
R6RS,
R7RS
HISTORY
These procedures first appeared in R2RS. They are missing from IEEE
Scheme.
AUTHORS
This page is part of the
scheme-manpages
project.
It includes materials from the RnRS documents.
More information can be found at
https://github.com/schemedoc/manpages/
.
Markup created by unroff 1.0sc, March 04, 2023.